<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>
    const obj = {
        name:"admin",
        age:18,
        sex:"男"
    }

    let str = "age";

    const obj2 = {
        // ["get " + str](){
        //     console.log(str+"属性被访问了")
        //     return obj[str];
        // },
        // ["set " + str](v){
        //     console.log(str+"属性被修改了")
        //     obj[str] = v;
        // }
        get [str](){
            console.log(str+"属性被访问了")
            return obj[str];
        },
        set [str](v){
            console.log(str+"属性被修改了")
            obj[str] = v;
        }
    }

    obj2[str];
    obj2[str] = "ahaahhahaah"

    obj2.xxx = "xxx";

    console.log(obj2);


</script>
</html>